package com.lock;

import org.springframework.stereotype.Component;

@Component
public class ConsistencyManager {
    //private static ThreadLocal<JSONObject> threadLocalAttributes = new ThreadLocal();


    static abstract class Consistency{
        void before(){
            System.out.println("before");
        }
        abstract void execute();
        void inject(){
            before();//mongodb check
            execute();//business
            after();//mongodb add
        }
        void after(){
            System.out.println("after");
        }
    }

    //注入
    static class ConsistencyHandlers extends Consistency{
        @Override
        void execute() {
        }
    }

    //入口
    static void inject(Consistency consistency){
        //redis分布式锁 try cath
        consistency.inject();
    }
}